﻿using Css_VoteSys.Service;
using Css_VoteSys.Models.Database;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;

namespace Css_VoteSys.Service
{
    public class ProjectService : IProjectService
    {
        private readonly Css_VoteSysContext _db;

        public ProjectService(Css_VoteSysContext db) {
            _db = db;
        }

        /// <summary>   
        /// 是否存在提交过该项目
        /// </summary>
        /// <param name="UserId"></param>
        /// <param name="CategoryId"></param>
        /// <returns></returns>
        public bool IsUserHasCategory(int UserId,int CategoryId) {   
            // 查询该用户是否提交过该项目 userId CategoryId
            if (_db.VoteProjects.Any(x => x.UserId == UserId && x.CategoryId ==CategoryId)) return true;
            return false;
        }
    }

 }
